from time import sleep
from page_locators.login_page_locator import LoginPageLocators as LPL
from common.base_page import BasePage 
from test_datas.pic_data import *


class PhotoAlbum(BasePage):

    def __init__(self, driver):
        super().__init__(driver)

    def class_photos_menu(self):
        self.click(LPL.class_photos_menu, "班级相册菜单定位失败截图")


    def grade_class_box(self):
        self.click(LPL.grade_class_box, "年级班级下拉框定位失败截图")
        self.click(LPL.class1_grade1, "一年级1班定位失败截图")

    def create_pic_albums(self):
        self.click(LPL.create_pic_albums, "创建相册按钮定位失败截图")

    def albums_name_error1(self):
        self.create_pic_albums()
        self.input(LPL.albums_name, "春季运动会", "创建相册/名称输入框定位失败截图")
        self.click(LPL.choose_class, "创建相册/所属班级定位失败截图")
        self.click(LPL.class1_1, "一年级1班定位失败截图")
        self.click(LPL.submit_albums, "提交按钮定位失败截图")

    def albums_name_error2(self):
        self.create_pic_albums()
        self.input(LPL.albums_name, "", "创建相册/名称输入框定位失败截图")
        self.click(LPL.choose_class, "创建相册/所属班级定位失败截图")
        self.click(LPL.class1_1, "一年级1班定位失败截图")
        self.click(LPL.submit_albums, "提交按钮定位失败截图")

    def albums_name_succwss1(self):
        self.click(LPL.create_pic_albums, "创建相册按钮定位失败截图")
        self.input(LPL.albums_name, " ", "创建相册/名称输入框定位失败截图")
        self.click(LPL.choose_class, "创建相册/所属班级定位失败截图")
        self.click(LPL.class1_1, "一年级1班定位失败截图")
        self.click(LPL.submit_albums, "提交按钮定位失败截图")


    def albums_name_succwss2(self):
        self.click(LPL.create_pic_albums, "创建相册按钮定位失败截图")
        self.input(LPL.albums_name, "春季运动会", "创建相册/名称输入框定位失败截图")
        self.click(LPL.choose_class, "创建相册/所属班级定位失败截图")
        self.click(LPL.class1_1, "一年级1班定位失败截图")
        self.click(LPL.submit_albums, "提交按钮定位失败截图")

    def albums_name_succwss3(self):
        self.click(LPL.create_pic_albums, "创建相册按钮定位失败截图")
        self.input(LPL.albums_name, "^&", "创建相册/名称输入框定位失败截图")
        self.click(LPL.choose_class, "创建相册/所属班级定位失败截图")
        self.click(LPL.class1_1, "一年级1班定位失败截图")
        self.click(LPL.submit_albums, "提交按钮定位失败截图")


    def choose_class_error(self):
        self.click(LPL.create_pic_albums, "创建相册按钮定位失败截图")
        self.input(LPL.albums_name, "春季运动会", "创建相册/名称输入框定位失败截图")
        self.click(LPL.choose_class, "创建相册/所属班级定位失败截图")
        self.click(LPL.submit_albums, "提交按钮定位失败截图")

    def choose_class_success(self):
        self.click(LPL.create_pic_albums, "创建相册按钮定位失败截图")
        self.input(LPL.albums_name, "冬季运动会", "创建相册/名称输入框定位失败截图")
        self.click(LPL.choose_class, "创建相册/所属班级定位失败截图")
        self.click(LPL.class1_2, "一年级2班定位失败截图")
        self.click(LPL.submit_albums, "提交按钮定位失败截图")

    def search_error1(self):
        self.input(LPL.search, "123", "搜索查找输入框定位失败截图")

    def search_error2(self):
        self.input(LPL.search, " ", "搜索查找输入框定位失败截图")

    def search_error3(self):
        self.input(LPL.search, "^", "搜索查找输入框定位失败截图")

    def search_success1(self):
        self.input(LPL.search, "冬季运动会", "搜索查找输入框定位失败截图")

    def search_success2(self):
        self.input(LPL.search, "运动会", "搜索查找输入框定位失败截图")

    def input_click(self):
        self.suspension_loc(LPL.first_albuns, LPL.input_click, "上传按钮定位失败截图")

    def input_pic_error1(self):
        self.input_click()
        self.upload_file(LPL.input_pic, webp_path, "上传标签定位失败截图")

    def input_pic_success1(self):
        self.input_click()
        self.upload_file(LPL.input_pic, general_path, "上传标签定位失败截图")
        self.wait(LPL.success_input)
        self.suspension_loc(LPL.pic, LPL.delete, "删除图标定位失败截图")

    def input_pic_success2(self):
        self.input_click()
        self.upload_file(LPL.input_pic, general_path, "上传标签定位失败截图")
        self.wait(LPL.success_input)
        self.click(LPL.unsure, "取消按钮定位失败截图")
        self.suspension_loc(LPL.first_albuns, LPL.view, "查看按钮定位失败截图")

    def input_pic_success3(self):
        self.input_click()
        self.upload_file(LPL.input_pic, general_path, "上传标签定位失败截图")
        self.wait(LPL.success_input)
        self.click(LPL.sure, "确定按钮定位失败截图")
        self.suspension_loc(LPL.first_albuns, LPL.view, "查看按钮定位失败截图")

    def delete_album(self, album):
        self.suspension_loc(album, LPL.dle, "删除按钮悬浮定位点击")
        self.click(LPL.sure_del, "确认删除定位点击")
        sleep(1)

    def input_pic_success4(self):
        self.input_pic_success3()

    def input_pic_success5(self):
        self.input_click()
        self.upload_file(LPL.input_pic, video_path, "上传标签定位失败截图")
        self.wait(LPL.success_input)
        self.click(LPL.sure, "确定按钮定位失败截图")
        self.suspension_loc(LPL.first_albuns, LPL.view, "查看按钮定位失败截图")


